package com.example.controller;

import com.example.pojo.Person;
import com.example.pojo.UserByGroup;
import com.example.validator.UserValidGroupOne;
import com.example.validator.UserValidGroupTwo;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;

/**
 * @program: springboot_course
 * @description: 分组案例
 * @author: ChenZhiXiang
 * @create: 2019-06-11 09:48
 **/
@RestController
public class ValidateDemoController {

    @RequestMapping(value = "/userByGroup1", method = RequestMethod.POST)
    public String printValidatedUserInfoByGroupOne(@RequestBody @Validated(value = {UserValidGroupOne.class}) UserByGroup userByGroup) {
        return userByGroup.toString();
    }

    @RequestMapping(value = "/userByGroup2", method = RequestMethod.POST)
    public String printValidatedUserInfoByGroupTwo(@RequestBody @Validated(value = {UserValidGroupTwo.class}) UserByGroup userByGroup) {
        return userByGroup.toString();
    }

    @RequestMapping(value = "/person", method = RequestMethod.POST)
    public String printValidatedPersonInfo(@RequestBody @Valid Person person) {
        return person.toString();
    }

}
